# snownlp适合电商其实，不适合做网络热词评论的情绪分析
from snownlp import SnowNLP
import pandas as pd

test_data = pd.read_csv("../nlp_date/train.csv")

for index, word in test_data.iterrows():
    s = SnowNLP(word['txt'])
    sentiments = s.sentiments
    # print(sentiments)
    if sentiments > 0.3:
        test_data.loc[index, 'label'] = 1

    else:
        test_data.loc[index, 'label'] = 0

test_data.to_csv('../nlp_date/train1.csv', index=False, encoding='utf_8_sig')
